import instance from '@/utils/axios.js';

//登录接口
function userLogin({
  mobile,
  code
}) {
  return instance({
    url: '/v1_0/authorizations',
    method: 'post',
    data: {
      mobile,
      code
    }
  })
}
export {
  userLogin
}
//获取个人信息
import {
  getToken
} from '@/utils/token.js'
const getUserInfo = () => {
  return instance({
    url: '/v1_0/user/profile',
    method: 'get',
    // 设置请求头
    headers: {
      // 调用方法 获取返回的对象 然后 点出 token
      Authorization: `Bearer ${getToken().token}`
    }
  })
}
export {
  getUserInfo
}
//更改用户呢称
const editUserInfo = data => {
  return instance({
    url: '/v1_0/user/profile',
    method: 'patch',
    data,
    headers: {
      Authorization: `Bearer ${getToken().token}`
    }
  })

}
export {
  editUserInfo
}
//上传头像
const editUserAvatar =fd =>{
  return instance({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data: fd,
    // 设置请求头
    headers: {
      // 调用方法 获取返回的对象 然后 点出 token
      Authorization: `Bearer ${getToken().token}`
    }
  })
}
export{editUserAvatar}
